home *** CD-ROM | disk | FTP | other *** search
- ;void println(strg);
- ; char *strg;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _time_out:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _println
- _println proc near
- jmp short start ;jmp over local data
- delay dw ? ;
- target dw ? ;
- start: push bp ;
- mov bp,sp ;set stack frame
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;save DS
- mov ah,1 ;BIOS func to init prtr
- mov dx,0 ;choose LPT1
- int 17h ;initialize the prtr port
- sub ax,ax ;AX = 0
- mov es,ax ;ES = 0
- mov dx,es:[408H] ;get LPT1 base address
- sub bx,bx ;0 = no error
- mov al,_time_out ;get _time_out seconds
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: or al,al ;don't allow zero seconds
- jnz L1 ;
- mov al,3 ;default to 3 seconds
- L1: mov cl,18 ;18 ticks per second
- mul cl ;
- mov cs:delay,ax ;save count
- cmp byte ptr[si],0 ;test for null string
- je L5 ;
- L2: mov al,[si] ;mov character to AL
- cmp al,0 ;end of string?
- je L5 ;
- inc si ;forward pointer for next time
- L3: out dx,al ;send to output data register
- inc dx ;forward to status register
- push cx ;save string counter
- push bx ;
- call GetBiosCount ;get timer reading
- mov bx,cx ;make copy
- add cx,cs:delay ;add delay count
- cmp bx,cx ;if timer doesn't turn over...
- jb L4 ;go ahead
- mov cx,cs:delay ;otherwise, extend delay
- L4: mov cs:target,cx ;save target count on stack
- pop bx ;
- Wait: in al,dx ;get status value
- test al,8 ;test for printer error
- jz Error ;
- test al,80h ;test for Printer Ready
- jnz Ready ;jump if ready
- Error: call GetBiosCount ;
- cmp cx,cs:target ;compare to target
- jb Wait ;
- mov bl,1 ;1 = error
- pop cx ;restore string counter
- jmp short L7 ;go quit routine
- Ready: pop cx ;restore string counter
- inc dx ; output control register
- mov al,13 ;bits for strobe signal
- out dx,al ;send the signal
- dec al ;change to strobe OFF
- out dx,al ;send the signal
- dec dx ;point back to
- dec dx ; base address
- jmp short L2 ;loop
- L5: inc cx ;will reenter loop
- cmp bh,2 ;BH = 0 first time around
- je L7 ;when 2, quit routine
- inc bh ;inc BH before looping
- cmp bh,2 ;second time?
- jne L6 ;jump ahead if not
- mov al,13 ;ready carriage return
- jmp short L3 ;go print it
- L6: mov al,10 ;ready line feed
- jmp short L3 ;go print it
- L7: pop ds ;restore DS
- mov _error_code,bl ;set _error_code
- pop si ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- GetBIOSCount PROC
- push dx ;return value in CX:DX
- push ax ;
- sub ah,ah ;function number
- int 1ah ;get timer count
- mov cx,dx ;low word in CX
- pop ax ;
- pop dx
- ret
- GetBIOSCount endp
- _println endp
- _TEXT ENDS
- END